<template>
    <div>
        <van-nav-bar title="标题" left-text="返回" left-arrow @click-left="onClickLeft" />
        <van-search v-model="value" shape="round" background="#4fc08d" placeholder="请输入搜索关键词" />
        <van-empty v-if="value.length == 0 || qsearch.length == 0"
            image="https://fastly.jsdelivr.net/npm/@vant/assets/custom-empty-image.png" image-size="80"
            description="描述文字" />



        <van-cell-group v-for="item in qsearch">
            <router-link :to="'/xq/' + item.goods_id">
                <van-cell :title="item.goods_name" value="内容" @click="dj" />

            </router-link>

        </van-cell-group>


    </div>
</template>

<script setup>
import { qsearchApi } from '@/api/api';
import router from '@/router';
import { ref, watch } from 'vue';
// import { useRoute } from 'vue-router';
let qsearch = ref([]);

let value = ref('');
watch(value, (val) => {
    console.log(value)
    qsearchApi(val).then(res => {
        console.log('搜索', res)
        qsearch.value = res.data.message;
    })
})
let onClickLeft = () => {
    router.push('/index/sy')
}
let dj = () => {
    router.push('/xq')
}


</script>

<style lang="scss" scoped></style>